const db = require("../../utils/db.js");
const util = require("../../utils/util.js");
// console.log(db)
Page({
	data: {
		detail: {}, //新闻详情
		id:""
	},
	onLoad(e) {
		var id = e.id;
		this.data.id=id;
		this.getDetail(id)
	},
	//页面刷新
	onPullDownRefresh(){
		var id=this.data.id;
		this.getDetail(id)
	},
	//页面分享
	onShareAppMessage(){

	},
	//获取详情
	async getDetail(id) {
		var result = await db.findById("news", id)
		var detail = result.data;
		detail.addtime = util.formatTime(new Date(detail.addtime))
		this.setData({
			detail: detail
		})
		wx.stopPullDownRefresh({
			success: (res) => {},
		})
	},
	//全屏预览图片
	preview(){
		wx.previewImage({
			urls:this.data.detail.images
		},false)
	}
})